package com.zxcrm.zxcrm.service.impl;

import java.util.List;
import com.zxcrm.common.utils.DateUtils;
import com.zxcrm.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zxcrm.zxcrm.mapper.ZxcrmCustomerMapper;
import com.zxcrm.zxcrm.domain.ZxcrmCustomer;
import com.zxcrm.zxcrm.service.IZxcrmCustomerService;

/**
 * 客户Service业务层处理
 * 
 * @author xu
 * @date 2025-07-07
 */
@Service
public class ZxcrmCustomerServiceImpl implements IZxcrmCustomerService 
{
    @Autowired
    private ZxcrmCustomerMapper zxcrmCustomerMapper;

    /**
     * 查询客户
     * 
     * @param id 客户主键
     * @return 客户
     */
    @Override
    public ZxcrmCustomer selectZxcrmCustomerById(Long id)
    {
        return zxcrmCustomerMapper.selectZxcrmCustomerById(id);
    }

    /**
     * 查询客户列表
     * 
     * @param zxcrmCustomer 客户
     * @return 客户
     */
    @Override
    public List<ZxcrmCustomer> selectZxcrmCustomerList(ZxcrmCustomer zxcrmCustomer)
    {
        return zxcrmCustomerMapper.selectZxcrmCustomerList(zxcrmCustomer);
    }

    /**
     * 新增客户
     * 
     * @param zxcrmCustomer 客户
     * @return 结果
     */
    @Override
    public int insertZxcrmCustomer(ZxcrmCustomer zxcrmCustomer)
    {
        zxcrmCustomer.setCreateTime(DateUtils.getNowDate());
        zxcrmCustomer.setInputMethod("1");
        zxcrmCustomer.setCreateBy(SecurityUtils.getUserId().toString());
        return zxcrmCustomerMapper.insertZxcrmCustomer(zxcrmCustomer);
    }

    /**
     * 修改客户
     * 
     * @param zxcrmCustomer 客户
     * @return 结果
     */
    @Override
    public int updateZxcrmCustomer(ZxcrmCustomer zxcrmCustomer)
    {
        zxcrmCustomer.setUpdateTime(DateUtils.getNowDate());
        zxcrmCustomer.setUpdateBy(SecurityUtils.getUserId().toString());
        return zxcrmCustomerMapper.updateZxcrmCustomer(zxcrmCustomer);
    }

    /**
     * 批量删除客户
     * 
     * @param ids 需要删除的客户主键
     * @return 结果
     */
    @Override
    public int deleteZxcrmCustomerByIds(Long[] ids)
    {
        return zxcrmCustomerMapper.deleteZxcrmCustomerByIds(ids);
    }

    /**
     * 删除客户信息
     * 
     * @param id 客户主键
     * @return 结果
     */
    @Override
    public int deleteZxcrmCustomerById(Long id)
    {
        return zxcrmCustomerMapper.deleteZxcrmCustomerById(id);
    }
}
